package listener;

import gui.ChessGUI;
import gui.PieceGUI;
import javafx.event.EventHandler;
import javafx.scene.Cursor;
import javafx.scene.input.MouseEvent;
import javafx.scene.shape.Circle;
import logic.Move;
import logic.Piece;

public class PieceHandlerMouseEntered implements EventHandler<MouseEvent> {

	private ChessGUI chessGUI;
	private PieceGUI pieceGUI;

	public PieceHandlerMouseEntered(ChessGUI chessGUI, PieceGUI pieceGUI) {
		this.chessGUI = chessGUI;
		this.pieceGUI = pieceGUI;
	}

	@Override
	public void handle(MouseEvent event) {
		pieceGUI.setCursor(Cursor.HAND);
		for (int i = Piece.COLUMN_A; i <= Piece.COLUMN_I; i++) {
			for (int j = Piece.ROW_1; j <= Piece.ROW_9; j++) {

				int sourceRow = pieceGUI.getY();
				int sourceCol = pieceGUI.getX();
				if (chessGUI
						.getChessGame()
						.getMoveValidator()
						.isMoveValid(new Move(sourceRow, sourceCol, j, i),
								false)) {
					javafx.scene.shape.Circle arc = new Circle((30 + i * 50),
							(30 + j * 50), 10);
					System.out.println(arc);
					chessGUI.addMarkPoint(arc);
				}
			}
		}
		chessGUI.showMarkPoints();
	}

}
